<?php

/**
*获取菜单
*$classid  分类ID
*/
function tag_menu($classid){
	$CataLog = new CataLog();
	$menu = $CataLog->getCatalogSon ($classid);
	if(is_array($menu)){
		foreach($menu as $key=>&$value){
			$value['dir'] = CREATEHTML ? nameClassAndId($value) :'/column.php?classid='.$value['id'];
		}
		return $menu;
	}
	return false;
}

/**
*获取当前路径
*$classid  分类ID
*/
function tag_route($classid){
	$CataLog = new CataLog();
	$nameClassArray = $CataLog->getCatalogSon($classid);
	if(CREATEHTML){
		return nameClassArry($nameClassArray);
	}else{
		$data = nameClassArry($nameClassArray);
		foreach($data as $k=>&$v){
			$v['menu'] = '/column.php?classid='.$v['id'];
		}
		return $data;
	}
}

/**
*获取信息
*/
function tag_new($classid,$num,$orderBy='+',$page='1'){
	return getCateGory($classid,$num,'','new','id',$orderBy,$page);
}
/**
*按照类别获取信息
*/
function tag_new_class($classid,$num,$orderBy='+',$page='1'){
	$dataArray = getCateGory($classid,$num,'','','id',$orderBy,$page);
	return $dataArray['class'];
}
/**
*获取热门
*/
function tag_hot($classid,$num){
	return getCateGory($classid,$num,'','new','xdid','-');
}

/**
*获取推荐
*/
function tag_elite($classid,$num){
	return getCateGory($classid,$num,'1','new','id','-');
}

/**
 *获取头条
 */
function tag_headline($classid){
	return getCateGory($classid,'1','2','new','id','-');
}


// 上一篇
function tag_new_up($id, $classid) {
	$db = new happy_db();
	$id = intval($id);
	$classid = intval($classid);
	$findkey[] = "classid = ".$classid;
	$findkey[] = "id > ".$id;
	$where = implode(' AND ', $findkey);
	$where = ' WHERE ' . $where;
	$orderby = 'ASC';
	$order = ' ORDER BY id ' . $orderby;
	$sql = 'SELECT * FROM #happy_arctnew';
	$sql .= $where . $order;
	$data = $db->getRow($sql);
	if(!empty($data)){
		$dir_Path = nameArticleAndId($data);
		$data['dir'] = CREATEHTML ?  $dir_Path .date('Ymd',$data['pubdate']).'/'.$data['id'].'.html' : '/article.php?id='.$data['id'];
		$data['link'] = "上一篇：<a href=\"{$data['dir']}\" title=\"{$data[title]}\">" . $data['title'] . "</a>" ;
		echo $data['link'];
	}
}

//下一篇
function tag_new_dn($id, $classid) {
	$db = new happy_db();
	$id = intval($id);
	$classid = intval($classid);
	$findkey[] = "classid = ".$classid;
	$findkey[] = "id < ".$id;
	$where = implode(' AND ', $findkey);
	$where = ' WHERE ' . $where;
	$orderby = 'DESC';
	$order = ' ORDER BY id ' . $orderby;
	$sql = 'SELECT * FROM #happy_arctnew';
	$sql .= $where . $order;
	$data = $db->getRow($sql);
	if(!empty($data)){
		$dir_Path = nameArticleAndId($data);
		$data['dir'] = CREATEHTML ?  $dir_Path .date('Ymd',$data['pubdate']).'/'.$data['id'].'.html' : '/article.php?id='.$data['id'];
		$data['link'] = "  下一篇：<a href=\"{$data['dir']}\" title=\"{$data[title]}\">" . $data['title'] . "</a>" ;
		echo $data['link'];
	}
}
?>